import App from 'next/app'

function MyApp({ Component, pageProps }) {
  return <Component {...pageProps} xxx={'yyy'}/>
}

// Only uncomment this method if you have blocking data requirements for
// every single page in your application. This disables the ability to
// perform automatic static optimization, causing every page in your app to
// be server-side rendered.
// ↓↓↓

MyApp.getInitialProps = async (appContext) => {
  // console.log('appContext:',appContext);
/*
appContext: { AppTree: [Function: AppTree],
  Component: { [Function: Home] getInitialProps: [AsyncFunction] },
  router:
   ServerRouter {
     route: '/',
     pathname: '/',
     query: {},
     asPath: '/index',
     isFallback: false },
  ctx:
   { err: undefined,
     req:
      IncomingMessage {
        _readableState: [ReadableState],
        readable: true,
        _events: [Object],
        _eventsCount: 1,
        _maxListeners: undefined,
        socket: [Socket],
        connection: [Socket],
        httpVersionMajor: 1,
        httpVersionMinor: 1,
        httpVersion: '1.1',
        complete: true,
        headers: [Object],
        rawHeaders: [Array],
        trailers: {},
        rawTrailers: [],
        aborted: false,
        upgrade: false,
        url: '/index',
        method: 'GET',
        statusCode: null,
        statusMessage: null,
        client: [Socket],
        _consuming: false,
        _dumped: false },
     res:
      ServerResponse {
        _events: [Object],
        _eventsCount: 1,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: false,
        chunkedEncoding: false,
        shouldKeepAlive: true,
        useChunkedEncodingByDefault: true,
        sendDate: true,
        _removedConnection: false,
        _removedContLen: false,
        _removedTE: false,
        _contentLength: null,
        _hasBody: true,
        _trailer: '',
        finished: false,
        _headerSent: false,
        socket: [Socket],
        connection: [Socket],
        _header: null,
        _onPendingData: [Function: bound updateOutgoingData],
        _sent100: false,
        _expect_continue: false,
        statusCode: 200,
        locals: {},
        flush: [Function: flush],
        write: [Function: write],
        end: [Function: end],
        on: [Function: on],
        writeHead: [Function: writeHead],
        [Symbol(isCorked)]: false,
        [Symbol(outHeadersKey)]: null },
     pathname: '/',
     query: {},
     asPath: '/index',
     AppTree: [Function: AppTree] } }

*/
  // calls page's `getInitialProps` and fills `appProps.pageProps`
  const appProps = await App.getInitialProps(appContext);
  console.log('appProps:', appProps);
/*
appProps: { pageProps: { someprops: { a: 1, b: 2 } } }
*/
  return {...appProps}
};

export default MyApp
